package com.qian.fmall.order.config;

import com.qian.fmall.mapper.OrderMapper;
import com.qian.fmall.pojo.Orders;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Component
public class QuartzCheckOutTime {
    @Resource
    private OrderMapper orderMapper;
    @Scheduled(cron = "0 1/1 * * * ? ")
    public void checkOrderTime()
    {
        List<Orders> ordersList=orderMapper.getAllNoPayOrder();
        for (Orders orders : ordersList) {
            long time = orders.getCreateTime().getTime();
            long now = new Date().getTime();
            if(now>time+1000*60*2)
            {
                int row=orderMapper.updateOrderDeleteTime(orders.getOrderId());
            }
        }
    }
}
